#!/usr/bin/python
# -*- coding: UTF-8 -*-

"""
@author: jiu
@contact: 643562684@qq.com
@time: 2022/3/10 16:44
"""
from faker import Factory
from datetime import datetime
from random import randint

"""
    折磨模块拿开创在一些数据例如： 地址街道手机号码，名字，性别 ，时间
"""


class DATAS(object):
    def __init__(self, lang: str = "zh_CN"):
        self.fake = Factory().create('zh_CN')
        self._min = 60
        self._max = 20000000
        self._multiple = 50

    @property
    def now_data(self):
        return str(datetime.now().strftime("%Y%m%d%H%M%S"))

    @property
    def random_phone_number(self):
        """
            随机号码
        :return:
        """
        return self.fake.phone_number()

    @property
    def random_name(self):
        """随机姓名"""
        return self.fake.name()

    @property
    def random_address(self):
        """
            随机地址
        :return:
        """
        return self.fake.address()

    @property
    def random_email(self):
        """
            随机 email
        :return:
        """
        return self.fake.email()

    @property
    def random_credit_card_number(self):
        """随机信用卡号"""
        return self.fake.credit_card_number()

    @property
    def random_ipv4(self):
        """随机ipv4 字段"""
        return self.fake.ipv4()

    @property
    def random_ssn(self):
        """随机身份证号"""
        return self.fake.ssn()

    @property
    def random_chrome_user_agent(self):
        """随机chrome的user agent 字段"""
        return self.fake.chrome()

    @property
    def random_date(self):
        """随机日期"""
        return self.fake.date()

    @property
    def random_car_number(self):
        """随机车牌号"""
        return self.fake.license_plate()

    @property
    def random_company_prefix(self):
        """公司前缀"""
        return self.fake.company_prefix()

    @property
    def random_company(self):
        """公司名字"""
        return self.fake.company()

    @property
    def random_company_suffix(self):
        """公司后缀"""
        return self.fake.company_suffix()

    @property
    def random_job(self):
        """随机工作"""
        return self.fake.job()

    @property
    def random_phonenumber_prefix(self):
        """运营商前三位"""
        return self.fake.phonenumber_prefix()

    @property
    def random_profile(self):
        """任人物信息"""
        return self.fake.profile()

    @property
    def random_text(self):
        """生成的文本"""
        return self.fake.text()

    @property
    def random_money(self):
        """随机缠身50 倍数的数"""
        return str(self._multiple * randint(self._min, self._max))

    def random_lvli(self, min: str = '', max: str = ''):
        """随机产生合法的年率率"""
        if isinstance(min, str):
            min = int(min.replace('%', ''))
        if isinstance(max, str):
            max = int(max.replace('%', ''))

        return randint(min, max)

    def _random_number(self, _min: int, _max: int, _mu=None):
        """随机出自己指定的范围内的数字 比较特殊"""
        return randint(_min, _max) if not _mu else randint(_min, _max) * _mu

    @staticmethod
    def random_user_info(number: int = 3):
        """
            接口自动的参数话值
        :return:
        """
        dt = DATAS()
        res = []

        for i in range(number):
            ssm = dt.random_ssn
            result = {
                "user_type": randint(0, 1),  # vip 类型
                "user_name": dt.random_name,  # 名称
                "mobile": dt.random_phone_number,
                "user_pwd": 'Zml199892',
                "user_pwd_confirm": 'Zml199892',
                "EMS": dt.random_phone_number,
                "address": dt.random_address,  # 家庭住址
                "real_name": dt.random_name,  # 名称
                "idno": ssm,  # 身份证信息
                "sex": randint(0, 1),
                "byear": ssm[6:10],
                "bmonth": ssm[10:12],  # 年份
                "bday": ssm[12:14],  # 月份
                "enterpriseName": dt.random_company,  # 企业认证里的公司名称,
                "bankLicense": dt.random_phone_number,  #
                "orgNo": dt.random_phone_number,
                "businessLicense": dt.random_car_number,
                "taxNo": randint(100, 9999),

            }
            res.append(result)

        return res


dt = DATAS()

# print(dt.random_money)
